package config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
	AliPay
}
type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type AliPay struct {
	AppId        string
	PrivateKey   string
	AliPublicKey string
	ReturnURl    string
	NotifyUrl    string
}

func Init() {

	viper.SetConfigFile("C:\\Users\\Lenovo\\Desktop\\zk3\\love-link\\love-server\\config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
		return
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic("配置文件连接失败")
		return
	} else {
		fmt.Println("配置文件连接成功")
	}
}
